﻿
using System.IO;
using EnvDTE80;
namespace MEFAddin
{
    public class AddInContext
    {
        private DTE2 _applicationObject;

        private EnvDTE.AddIn _addInInstance;

        private string _workingDirectory;

        private string _uiDLL;

        /// <summary>
        /// Initializes a new instance of the <see cref="AddInContext"/> class.
        /// </summary>
        /// <param name="addInInst">The add in inst.</param>
        public AddInContext(object addInInst)
        {
            this._workingDirectory = Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location);
            this._uiDLL = Path.Combine(_workingDirectory, "ACSR.SqlServer.Addin.Core.UI.dll");
            //this._uiDLL = Path.Combine(_workingDirectory, "MEFAddin.dll");
            this._addInInstance = (EnvDTE.AddIn)addInInst;
            this._applicationObject = (DTE2)_addInInstance.DTE;
        }

        /// <summary>
        /// Gets the application object.
        /// </summary>
        public DTE2 ApplicationObject
        {
            get
            {
                return _applicationObject;
            }
        }

        /// <summary>
        /// Gets the add in instance.
        /// </summary>
        public EnvDTE.AddIn AddInInstance
        {
            get
            {
                return _addInInstance;
            }
        }

        /// <summary>
        /// Gets the working directory.
        /// </summary>
        public string WorkingDirectory
        {
            get
            {
                return this._workingDirectory;
            }
        }

        /// <summary>
        /// Gets the UI DLL.
        /// </summary>
        public string UIDll
        {
            get
            {
                return this._uiDLL;
            }
        }
    }
}
